package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Grade;
import cn.wolfcode.crm.mapper.GradeMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.service.IGradeService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GradeServiceImpl implements IGradeService {
    @Autowired
    private GradeMapper mapper;

    public void deleteByPrimaryKey(Long id) {
        mapper.deleteByPrimaryKey(id);
    }



    public void insert(Grade record) {
        mapper.insert(record);

    }

    public Grade selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<Grade> selectAll() {
        return mapper.selectAll();
    }

    public void updateByPrimaryKey(Grade record) {
        mapper.updateByPrimaryKey(record);
    }
    public PageResult query(QueryForObject qo) {
        int total = mapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<Grade> rows = mapper.queryForList(qo);

        return new PageResult(total, rows);
    }

    public void changeState(Long id) {
        mapper.changeState(id);
    }


}
